﻿using FastORM.Applicaiton;
using FastORM.Enum;
using FastUtil.Config;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;

namespace FastCore.Test.ORM
{
    [TestClass]
    public class RowOperate
    {
        [TestMethod]
        public void Insert()
        {
            CommonRow row = new CommonRow("Frame_User", "UserGuid", DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            row["DisplayName"] = "RowYanpeng";
            row["LoginID"] = "1233998";
            row["Mobile"] = "15100990000";
            row["Age"] = 28;
            row["Birthday"] = "1994-01-19";
            row["Salary"] = 12000;
            row.Insert();
        }

        [TestMethod]
        public void InsertWithKeyGuid()
        {
            CommonRow row = new CommonRow("Frame_User", "UserGuid","20200104bilibili_coderoc", DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            row["DisplayName"] = "BiliBili";
            row["LoginID"] = "BiliBili";
            row["Mobile"] = "15100990000";
            row["Age"] = 28;
            row["Birthday"] = "1994-01-19";
            row["Salary"] = 12000;
            row.Insert();
        }

        [TestMethod]
        public void FindAndUpdate()
        {
            CommonRow row = new CommonRow("Frame_User", "UserGuid", "2020010421093096bf4d2a-414c-4f92-b251-3249d70917a4", DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            if (row.Exist())
            {
                row["Gender"] = 2;
                row.Update();
            }
        }

        [TestMethod]
        public void FindAndDelete()
        {
            CommonRow row = new CommonRow("Frame_User", "DisplayName", "颜鹏_99", DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            if (row.Exist())
            {
                row.Delete();
            }
        }
    }
}
